﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace FinApp.Controls {
    public abstract class ViewControlBase : Control {

        #region Methods
        protected DoubleAnimation CreateDoubleAnimation(double? beginTimeSeconds, double durationSeconds, double? toValue, DependencyObject target, string propertyPath, IEasingFunction easingFunction = null) {
            DoubleAnimation doubleAnimation = new DoubleAnimation();
            if (beginTimeSeconds != null) {
                doubleAnimation.BeginTime = TimeSpan.FromSeconds(beginTimeSeconds.Value);
            }
            doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(durationSeconds));
            doubleAnimation.To = toValue;
            doubleAnimation.EasingFunction = easingFunction;
            Storyboard.SetTarget(doubleAnimation, target);
            Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath(propertyPath));
            return doubleAnimation;
        }

        protected PointAnimation CreatePointAnimation(double? beginTimeSeconds, double durationSeconds, Point? toValue, DependencyObject target, string propertyPath, IEasingFunction easingFunction = null) {
            PointAnimation pointAnimation = new PointAnimation();
            if (beginTimeSeconds != null) {
                pointAnimation.BeginTime = TimeSpan.FromSeconds(beginTimeSeconds.Value);
            }
            pointAnimation.Duration = new Duration(TimeSpan.FromSeconds(durationSeconds));
            pointAnimation.To = toValue;
            pointAnimation.EasingFunction = easingFunction;
            Storyboard.SetTarget(pointAnimation, target);
            Storyboard.SetTargetProperty(pointAnimation, new PropertyPath(propertyPath));
            return pointAnimation;
        } 
        #endregion

    }
}
